#!/bin/sh

## trouble with mysql55 for qmail-toaster
sed -i 's/exclude\=mysql51/exclude\=mysql5/g' /etc/yum.repos.d/STatwork.repo

if [ ! -L /usr/bin/chkconfig ] ; then
	## ST -- fix issue if running restart in cron
	ln -s /sbin/chkconfig /usr/bin/chkconfig
fi

. /script/counter-start.inc

## ST -- importance for CentOS 6+ for cp/mv/rm
# sh /script/disable-alias

t=$(mysql -V|awk '{print $5}')
u=$(echo $t|grep -i '5.0.')

if [ "$u" != "" ] ; then
	echo "Need update mysql first..."
	echo "- Run 'yum replace mysql --replace-with=mysql55'" 
	echo "- For OpenVZ VPS, add 'innodb_use_native_aio=0' under '[mysqld]' in '/etc/my.cnf'"
	exit
fi

chkconfig kloxo on

for i in $(ls -ld /opt/php* | awk '{print $9}' | sed 's:/opt/::g' | tr '\n' ' ') ; do
	if [ "$(readlink /usr/bin/${i}-cli)" == "/opt/${i}/custom/${i}-cli.sh" ] ; then
		sh /script/phpm-installer $i -y
	fi
done

sh /script/fixlxphpexe

## ST -- no need always use 'fpm' mode
#sh /script/set-kloxo-php

. /script/directory
lxphp.exe ../bin/common/cleanup.php

echo
echo "*** Restart services - BEGIN ***"
sh /script/restart-all --force
echo "*** Restart services - END ***"
echo

. /script/counter-end.inc

